# -*- coding: utf-8 -*-
# @Time    : 2019/11/4 22:56
# @Author  : LiHaowen
# @Email   : lihaowen2017@163.com
# @File    : gen_to_coroutine.py

# 生成器是可以暂停的函数
import inspect


# def gen_func():
#     value = yield 1
#     # 1. 返回值给调用方，2. 调用方通过send方式返回给gen
#     return "b1"

# 用同步的方式编写异步的代码，在适当的时候暂停函数并在适当的时候启动函数
import socket
def downloader(url):
    client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    client.setblocking(False)
    # try:
        # client.connect((host,80))

if __name__ == '__main__':
    # gen = gen_func()
    # print(inspect.getgeneratorstate(gen))
    # next(gen)
    # print(inspect.getgeneratorstate(gen))
    # try:
    #     next(gen)
    # except StopIteration:
    #     pass
    # print(inspect.getgeneratorstate(gen))
    pass
